/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package flames.view;

import com.sun.awt.AWTUtilities;

import java.awt.Color;
import java.awt.Insets;
import java.awt.Point;

/**
 * @author 10373
 */
public class SecuritySetting extends javax.swing.JFrame {

    private Point pressedPoint;
    public final Color NORMAL_COLOR = new Color(132, 132, 132);   // #848484
    public final Color ACTIVE_COLOR = new Color(242, 135, 24);    // #f28718

    /**
     * Creates new form NewJFrame
     */
    private SecuritySetting() {
        this.setUndecorated(true);     // 只有在窗体不可显示时才调用此方法
        this.setResizable(false);   // 设置不可以重置窗口大小
        this.getContentPane().setBackground(Color.white);   // 设置背景颜色
        this.setSize(1230, 810);
        this.setLocationRelativeTo(null);   // 设置居中
        initComponents();
        AWTUtilities.setWindowOpacity(this, 0.99f); // 透明度
        AWTUtilities.setWindowOpaque(this, false);  // 通透
        Head.setOpaque(true);   // 设置透明
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        ShadowLayeredPane = new DropShadowPanel(15);
        mainLayeredPane = new javax.swing.JLayeredPane();
        SecurityToolsBKG1 = new javax.swing.JLabel();
        LineFlag_Font_Label = new javax.swing.JLabel();
        Logo = new javax.swing.JLabel();
        Head = new javax.swing.JLabel();
        securitySettingImg = new javax.swing.JLabel();
        minimizeButton = new javax.swing.JButton();
        existButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                formMouseDragged(evt);
            }
        });
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                mainFrameMousePressed(evt);
            }
        });

        ShadowLayeredPane.setBackground(new java.awt.Color(255, 255, 255));

        mainLayeredPane.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        SecurityToolsBKG1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/SecurityToolsPane/Security_Tools_BKG.png"))); // NOI18N
        SecurityToolsBKG1.setToolTipText("");
        SecurityToolsBKG1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                SecurityToolsBKG1MouseDragged(evt);
            }
        });
        SecurityToolsBKG1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                SecurityToolsBKG1MousePressed(evt);
            }
        });
        mainLayeredPane.add(SecurityToolsBKG1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1230, 870));

        LineFlag_Font_Label.setFont(new java.awt.Font("新宋体", 1, 30)); // NOI18N
        LineFlag_Font_Label.setForeground(new java.awt.Color(51, 51, 51));
        LineFlag_Font_Label.setText("设置");
        mainLayeredPane.setLayer(LineFlag_Font_Label, javax.swing.JLayeredPane.MODAL_LAYER);
        mainLayeredPane.add(LineFlag_Font_Label, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 0, 90, 50));

        Logo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_Flames.png"))); // NOI18N
        mainLayeredPane.setLayer(Logo, javax.swing.JLayeredPane.MODAL_LAYER);
        mainLayeredPane.add(Logo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, -10, 60, 60));

        Head.setBackground(new java.awt.Color(248, 249, 249));
        mainLayeredPane.setLayer(Head, javax.swing.JLayeredPane.PALETTE_LAYER);
        mainLayeredPane.add(Head, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 1230, 50));

        securitySettingImg.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/SecuritySetting.png"))); // NOI18N
        mainLayeredPane.setLayer(securitySettingImg, javax.swing.JLayeredPane.PALETTE_LAYER);
        mainLayeredPane.add(securitySettingImg, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, 1170, 640));

        minimizeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_minimize.png"))); // NOI18N
        minimizeButton.setAlignmentY(0.0F);
        minimizeButton.setFocusPainted(false);
        minimizeButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                minimizeButtonMouseEntered(evt);
            }

            public void mouseExited(java.awt.event.MouseEvent evt) {
                minimizeButtonMouseExited(evt);
            }
        });
        minimizeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                minimizeButtonActionPerformed(evt);
            }
        });

        existButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/flames/images/mainFrame/main_close.png"))); // NOI18N
        existButton.setAlignmentY(0.0F);
        existButton.setFocusPainted(false);
        existButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                existButtonMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                existButtonMouseExited(evt);
            }
        });
        existButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                existButtonActionPerformed(evt);
            }
        });

        ShadowLayeredPane.setLayer(mainLayeredPane, javax.swing.JLayeredPane.DEFAULT_LAYER);
        ShadowLayeredPane.setLayer(minimizeButton, javax.swing.JLayeredPane.PALETTE_LAYER);
        ShadowLayeredPane.setLayer(existButton, javax.swing.JLayeredPane.PALETTE_LAYER);

        javax.swing.GroupLayout ShadowLayeredPaneLayout = new javax.swing.GroupLayout(ShadowLayeredPane);
        ShadowLayeredPane.setLayout(ShadowLayeredPaneLayout);
        ShadowLayeredPaneLayout.setHorizontalGroup(
                ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(mainLayeredPane)
                        .addGroup(ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ShadowLayeredPaneLayout.createSequentialGroup()
                                        .addGap(0, 1175, Short.MAX_VALUE)
                                        .addComponent(existButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, ShadowLayeredPaneLayout.createSequentialGroup()
                                        .addContainerGap(1115, Short.MAX_VALUE)
                                        .addComponent(minimizeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(59, 59, 59)))
        );
        ShadowLayeredPaneLayout.setVerticalGroup(
                ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(mainLayeredPane, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(ShadowLayeredPaneLayout.createSequentialGroup()
                                        .addGap(0, 0, 0)
                                        .addComponent(existButton)
                                        .addContainerGap(830, Short.MAX_VALUE)))
                        .addGroup(ShadowLayeredPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(ShadowLayeredPaneLayout.createSequentialGroup()
                                        .addComponent(minimizeButton)
                                        .addGap(0, 830, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addComponent(ShadowLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(5, 5, 5))
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(ShadowLayeredPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // 切换样式
    private void toggleExistButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(Color.red);
        }
    }

    // 切换样式
    private void toggleNormalButtonStyle(javax.swing.JButton button) {
        if (button.isContentAreaFilled()) {
            button.setContentAreaFilled(false);
        } else {
            button.setContentAreaFilled(true);
            button.setBackground(Color.gray);
        }
    }

    // 使面板支持拖拽
    private void mainFrameMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainFrameMousePressed
        pressedPoint = evt.getPoint();// 记录鼠标坐标
    }//GEN-LAST:event_mainFrameMousePressed

    // 使面板支持拖拽
    private void formMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseDragged
        Point point = evt.getPoint();// 获取当前坐标
        Point locationPoint = getLocation();// 获取窗体坐标
        int x = locationPoint.x + point.x - pressedPoint.x;// 计算移动后的新坐标
        int y = locationPoint.y + point.y - pressedPoint.y;
        setLocation(x, y);// 改变窗体位置,（按钮可以使用边界布局,也可以使用绝对布局）

    }//GEN-LAST:event_formMouseDragged

    // 点击退出按钮, 触发该方法
    private void existButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_existButtonActionPerformed
//        System.exit(0);
        this.setVisible(false); // 回收该窗体资源, 关闭窗口
    }//GEN-LAST:event_existButtonActionPerformed

    // 切换样式
    private void existButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_existButtonMouseEntered
        toggleExistButtonStyle(existButton);
    }//GEN-LAST:event_existButtonMouseEntered

    // 切换样式
    private void existButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_existButtonMouseExited
        toggleExistButtonStyle(existButton);
    }//GEN-LAST:event_existButtonMouseExited

    // 切换样式
    private void minimizeButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_minimizeButtonMouseEntered
        toggleNormalButtonStyle(minimizeButton);
    }//GEN-LAST:event_minimizeButtonMouseEntered

    // 切换样式
    private void minimizeButtonMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_minimizeButtonMouseExited
        toggleNormalButtonStyle(minimizeButton);
    }//GEN-LAST:event_minimizeButtonMouseExited

    // 点击[最小化]按钮, 将触发该方法
    private void minimizeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minimizeButtonActionPerformed
        this.setExtendedState(this.ICONIFIED);  // set minimize
    }//GEN-LAST:event_minimizeButtonActionPerformed

    // 使面板支持拖拽
    private void SecurityToolsBKG1MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SecurityToolsBKG1MouseDragged
        formMouseDragged(evt);
    }//GEN-LAST:event_SecurityToolsBKG1MouseDragged

    // // 使面板支持拖拽
    private void SecurityToolsBKG1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SecurityToolsBKG1MousePressed
        mainFrameMousePressed(evt);
    }//GEN-LAST:event_SecurityToolsBKG1MousePressed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                SecuritySetting.runInstance();
            }
        });
    }

    public static SecuritySetting securitySettingFrame;
    public static void runInstance() {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                if (securitySettingFrame == null) {
                    securitySettingFrame = new SecuritySetting();
                }
                // 美化图标
                securitySettingFrame.setVisible(true);
                securitySettingFrame.existButton.setBorderPainted(false);
                securitySettingFrame.existButton.setMargin(new Insets(0, 0, 0, 0));
                securitySettingFrame.existButton.setContentAreaFilled(false);

                securitySettingFrame.minimizeButton.setBorderPainted(false);
                securitySettingFrame.minimizeButton.setMargin(new Insets(0, 0, 0, 0));
                securitySettingFrame.minimizeButton.setContentAreaFilled(false);

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Head;
    private javax.swing.JLabel LineFlag_Font_Label;
    private javax.swing.JLabel Logo;
    private javax.swing.JLabel SecurityToolsBKG1;
    private javax.swing.JLayeredPane ShadowLayeredPane;
    private javax.swing.JButton existButton;
    private javax.swing.JLayeredPane mainLayeredPane;
    private javax.swing.JButton minimizeButton;
    private javax.swing.JLabel securitySettingImg;
    // End of variables declaration//GEN-END:variables
}


